package practice2;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * An item for auction.
 *
 * @author Christian Bauer
 */
public class Item implements Serializable{

    private Long id = null;
    private int version = 0;

    private String name;
    private String description;

    private Date startDate;
    private Date endDate;

    private Set<Bid> bids = new HashSet<Bid>();
    
	private Date created = new Date();

    /**
     * No-arg constructor for JavaBean tools.
     */
    public Item() {}

    /**
     * Simple constructors
     */
    public Item(String name, String description,
                Date startDate, Date endDate) {
        this.name = name;
        this.description = description;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public Long getId() { return id; }
    public int getVersion() { return version; }

    public String getName() { return name; }

    public String getDescription() { return description; }
    public void setDescription(String description) { this.description = description; }

    public Date getStartDate() { return startDate; }

    public Date getEndDate() { return endDate; }

    public Set<Bid> getBids() { return bids; }
    public void addBid(Bid bid) {
        if (bid == null)
            throw new IllegalArgumentException("Can't add a null Bid.");
        this.getBids().add(bid);
        // Don't have to set the "other" side, a Bid can only be instantiated with a given item
    }

    public Date getCreated() { return created; }


}
